package com.zh.freechat.domain.user.repository;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zh.freechat.domain.user.entity.ChatUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;


/**
 * @author ZH
 * @date 23:21 2021/5/15
 */
@Mapper
public interface UserRepository extends BaseMapper<ChatUser> {

    @Update(value = "UPDATE ch_user SET status=#{status} WHERE uid=#{uid}")
    int updateStatus(@Param("uid") String uid, @Param("status") Integer status);

    @Select(value = "SELECT username FROM ch_user WHERE uid=#{uid} ")
    String getUsernameByUid(@Param("uid") String uid);

    @Select(value = "SELECT uid FROM ch_user WHERE username=#{username}")
    String getUidByUsername(@Param("username") String username);

}
